// packageC/pages/detailTheater/detailTheater.js
Page({
    /**
     * 页面的初始数据
     */
    data: {
      curCinema:{},
      relaCinemaList:[],
      longitude: 116.397455, // 天安门
      latitude: 39.909187,
      markers: [
        {
            iconPath: "/assets/imgs/location.png",
            id: 1,
            longitude: 116.512841, // 初始点-大族广场
            latitude: 39.791810,
            width: 50,
            height: 50
          },{
              iconPath: "/assets/imgs/target_loc.png",
              id: 2,
              longitude: 116.397455,
              latitude: 39.909187,
              width: 50,
              height: 50
          }
      ],
      polyline: [{
        points: [{
            longitude: 116.512841, // 初始线-大族广场
            latitude: 39.791810,
        }, {
            longitude: 116.397455,
            latitude: 39.909187,
        }],
        color:"#FF0000DD",
        width: 3,
        dottedLine: true
      }],
      controls: [{
        id: 3,
  //       iconPath: '/assets/imgs/xxx.png',
  //       position: {
  //         left: 0,
  //         top: 50,
  //         width: 50,
  //         height: 50
  //       },
  //       clickable: true
      }]
    },
  
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let id=options.id;
        let cinemaList = getApp().globalData.cinemaList
        let curCinema = cinemaList.find(it=>it.id==id);

        let longitude = curCinema.longitude;
        let latitude = curCinema.latitude;
        let markers = this.data.markers;
        markers[1].longitude=longitude;
        markers[1].latitude=latitude;
        let polyline = this.data.polyline;
        polyline[0].points[1].longitude=longitude;
        polyline[0].points[1].latitude=latitude;

        this.setData({longitude});
        this.setData({latitude});
        this.setData({markers});
        this.setData({polyline});
        this.setData({curCinema});

        let relaCinemaList = cinemaList.filter(it=>it.id!=id);
        this.setData({relaCinemaList});
    },
    regionchange(e) {
      console.log(e.type)
    },
    markertap(e) {
      console.log(e.detail.markerId)
    },
    controltap(e) {
      console.log(e.detail.controlId)
    },
    toOtherPath(e){
      wx.navigateTo({
        url: './detailTheater?id='+e.currentTarget.dataset.id,
      })
    },
    onShareAppMessage: function (res){
      return {
        title: '电影之家',
        path: './detailTheater?id='+this.data.curCinema.id
      }
    },
  })